package com.ztao.controller;

import com.heima.model.common.apArticle.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import com.ztao.common.constants.ArticleConstants;
import com.ztao.service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {
    @Resource
    private ArticleService articleService;
//    @PostMapping("/load")
//    public ResponseResult load(@RequestBody ArticleHomeDto dto){
//        return  this.articleService.load(dto,0);
//    }
    @PostMapping("/loadnew")
    public ResponseResult load1(@RequestBody ArticleHomeDto dto){
        return  this.articleService.load(dto,2);
    }

    @PostMapping("/loadmore")
    public ResponseResult load2(@RequestBody ArticleHomeDto dto){
        return  this.articleService.load(dto,1);
    }



    /**
     * 加载首页
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        //        return apArticleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return articleService.load2(dto, ArticleConstants.LOADTYPE_LOAD_MORE,true);
    }
}
